package com.projectcost.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.projectcost.common.annotation.Log;
import com.projectcost.common.enums.BusinessType;
import com.projectcost.system.domain.functionManagement;
import com.projectcost.system.service.IfunctionManagementService;
import com.projectcost.common.core.controller.BaseController;
import com.projectcost.common.core.domain.AjaxResult;
import com.projectcost.common.utils.poi.ExcelUtil;
import com.projectcost.common.core.page.TableDataInfo;

/**
 * 计算功能点Controller
 * 
 * @author projectcost
 * @date 2024-11-21
 */
@Controller
@RequestMapping("/system/functionpoint")
public class functionManagementController extends BaseController
{
    private String prefix = "system/functionpoint";

    @Autowired
    private IfunctionManagementService functionManagementService;

    @RequiresPermissions("system:functionpoint:view")
    @GetMapping()
    public String functionpoint()
    {
        return prefix + "/functionpoint";
    }

    /**
     * 查询计算功能点列表
     */
    @RequiresPermissions("system:functionpoint:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(functionManagement functionManagement)
    {
        startPage();
        List<functionManagement> list = functionManagementService.selectfunctionManagementList(functionManagement);
        return getDataTable(list);
    }

    /**
     * 导出计算功能点列表
     */
    @RequiresPermissions("system:functionpoint:export")
    @Log(title = "计算功能点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(functionManagement functionManagement)
    {
        List<functionManagement> list = functionManagementService.selectfunctionManagementList(functionManagement);
        ExcelUtil<functionManagement> util = new ExcelUtil<functionManagement>(functionManagement.class);
        return util.exportExcel(list, "计算功能点数据");
    }

    /**
     * 新增计算功能点
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存计算功能点
     */
    @RequiresPermissions("system:functionpoint:add")
    @Log(title = "计算功能点", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(functionManagement functionManagement)
    {
        return toAjax(functionManagementService.insertfunctionManagement(functionManagement));
    }

    /**
     * 修改计算功能点
     */
    @RequiresPermissions("system:functionpoint:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        functionManagement functionManagement = functionManagementService.selectfunctionManagementById(id);
        mmap.put("functionManagement", functionManagement);
        return prefix + "/edit";
    }

    /**
     * 修改保存计算功能点
     */
    @RequiresPermissions("system:functionpoint:edit")
    @Log(title = "计算功能点", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(functionManagement functionManagement)
    {
        return toAjax(functionManagementService.updatefunctionManagement(functionManagement));
    }

    /**
     * 删除计算功能点
     */
    @RequiresPermissions("system:functionpoint:remove")
    @Log(title = "计算功能点", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(functionManagementService.deletefunctionManagementByIds(ids));
    }
}
